postData.Method = 'Q'

$(function(){
    _gridInit();    
    $('li[data-opt="add"]').on('click', function(){
        window.open('MDM003502.html', '_blank');
    });
});

function alarmFormatter(cellvalue, options, rowdata){
    var grid = $(this);
    if(JSON.stringify(rowdata)!=='{}'){
        cellvalue = '<a href="javascript:0" opt-data="'+grid[0].id+'_edit1" title="编辑分类及其展示产品"><i class="fa fa-pencil"></i><span>&nbsp;分类及其展示产品</span></a>'+
            '&nbsp;<a href="javascript:0" opt-data="'+grid[0].id+'_edit2" title="编辑品牌和销售排行榜"><i class="fa fa-pencil"></i><span>&nbsp;品牌和销售排行榜</span></a>';
    }else{
        cellvalue = '';
    }
    return cellvalue;
}

function _gridInit(){

    var gridData01 = Object.create(gridData);

    gridData01.url = mdmPath + '/MDM0035/MDM003502';
    gridData01.colModel = [
        {label:'代码', name:'Code'},
        {label:'名称', name:'Name'},
        // {label:'创建时间', name:'CreateDate'},
        {label:'创建用户', name:'CreateUser'},
        // {label:'更新时间', name:'UpdateDate'},
        {label:'更新用户', name:'UpdateUser'},
        {label:'操作', name:'Options', width:300, align:'center', formatter: alarmFormatter, sortable:false}
    ];
    gridData01.rowNum = 20;
    gridData01.sortname = 'Code';

    console.log(gridData)
    console.log(gridData01);

    postData.Content = {"SearchText":''};
    gridWidth = $(".u_toolbar");

    gridData01.loadComplete = function(xhr){
        xhr.Status == -999 && alert_QX($('body'), xhr.Message);
        $('a[opt-data="jgTable_edit1"]').unbind('click').bind('click', function(){
            var rowId = $(this).parent().parent()[0].id;
            var rowData = gridData01.grid.jqGrid("getRowData", rowId);
            window.open('MDM003502.html?Code=' + rowData['Code'], '_blank');
        });
        $('a[opt-data="jgTable_edit2"]').unbind('click').bind('click', function(){
            var rowId = $(this).parent().parent()[0].id;
            var rowData = gridData01.grid.jqGrid("getRowData", rowId);
            window.open('MDM003503.html?Code=' + rowData['Code'], '_blank');
        });
    }

    // gridData01.ondblClickRow = function(rowid,iRow,iCol,e){
    //     var rowData = gridData01.grid.jqGrid("getRowData", rowid);
    //     window.open('MDM003502.html?Code=' + rowData['Code'], '_blank');
    // }

    gridInit(gridData01);

}







